package com.itany.springboot.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 用户实体
 * @author 李恒
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User implements Serializable {
    private Integer id;
    private String username;
    private String password;
    private String sex;
    private String edu;
    private String[] hobbies;
    private String description;
    @DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss")
    private Date registDate;
    private String status;


    public static final String HOBBIES_SPLIT=",";



    public void setHob(String hob){
        if(hob!=null){
            hobbies=hob.split(HOBBIES_SPLIT);
        }
    }

    public String getHob(){
        if(hobbies!=null){
            return String.join(HOBBIES_SPLIT,hobbies);
        }
        return null;
    }

}
